﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DAO;
using System.Data;
using DTO;
namespace DAO
{
    public class CTPhieuYeuCauNLDB
    {
        DataProvider dp = new DataProvider();
        DataTable dt = new DataTable();
        public void ThemCTPhieuYCNL(CTPhieuYeuCauNL dto)
        {
            string sql = "insert into CTPhieuYeuCauNL(MaPhieuYC,MaNL,SoLuongYC) values (" + dto.MaPhieuYC + "," + dto.MaNL + "," + dto.SoLuongYeuCau + ")";
            dp.ExecuteNonQuery(sql);
        }
        //Lấy danh sach chi tiết phiếu yêu cầu_________________________________________________________________________________________________________________
        public DataTable dLayDSChiTietPhieuYC()
        {
            string sql = "select ct.MaPhieuYC,nvl.TenNL,nvl.LoaiNL,nvl.DonVi,ct.SoLuongYC from NguyenVatLieu nvl, CTPhieuYeuCauNL ct where ct.MaNL=nvl.MaNL";
            return dt = dp.ExecuteQuery(sql);
        }
        //Lấy Chi tiết phiếu yêu cầu theo mã phiếu yêu cầu
        public DataTable dLayChiTietPhieuYC(int MaPYC)
        {
            string sql = "select ct.MaNL, ct.MaPhieuYC,nvl.TenNL,nvl.LoaiNL,nvl.DonVi,ct.SoLuongYC from NguyenVatLieu nvl, CTPhieuYeuCauNL ct where ct.MaNL=nvl.MaNL and MaPhieuYC = '" + MaPYC + "'";
            return dt = dp.ExecuteQuery(sql);
        }
    }
}
